#include "cpu/exec/template-start.h"

#define instr cmp

static void do_execute() {
    DATA_TYPE dest_val = op_dest->val;
    DATA_TYPE src_val = op_src->val;
    
    // 正确顺序：dest - src
    DATA_TYPE result = dest_val - src_val;
    
    // 更新标志位
    update_eflags_pf_zf_sf((DATA_TYPE_S)result);
    
    // 正确计算CF（无符号借位）
    cpu.eflags.CF = (uint64_t)dest_val < (uint64_t)src_val;
    
    // 正确计算OF（有符号溢出）
    cpu.eflags.OF = MSB((dest_val ^ src_val) & (dest_val ^ result));
    
    print_asm_template2();
}

make_instr_helper(i2a)
make_instr_helper(i2rm)
make_instr_helper(r2rm)
make_instr_helper(rm2r)
#if DATA_BYTE == 2 || DATA_BYTE == 4
make_instr_helper(si2rm)
#endif

#include "cpu/exec/template-end.h"